package edu.snake.implement;

import edu.snake.core.model.Character.CharacterName;

public class Utils {
    public static CharacterName StringToCharacterNames(String s) {
        if (s.trim().toUpperCase().equals(CharacterName.BORDER.toString())) {
            return CharacterName.BORDER;
        }

        if (s.trim().toUpperCase().equals(CharacterName.SNAKE.toString())) {
            return CharacterName.SNAKE;
        }

        if (s.trim().toUpperCase().equals(CharacterName.FROG.toString())) {
            return CharacterName.FROG;
        }

        if (s.trim().toUpperCase().equals(CharacterName.EMPTY.toString())) {
            return CharacterName.EMPTY;
        }
        return CharacterName.NOT_USED;
    }

    /**
     * Simple validation helper method to validate if a given
     * Object is not null
     *
     * @param obj Object to verify is not null
     * @param message Message to describe which object should not be null
     */
    public static void requireNonNull(Object obj, String message) {
        if(obj == null) {
            throw new IllegalArgumentException(message);
        }
    }
}
